<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class ShippingTemplatesFree extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;
    /**
     * 计费方式
     */
    public $typeLet = [
        'typeLet_one' => '按件数',
        'typeLet_two' => '按重量',
        'typeLet_three' => '按体积',
    ];

    /**
     * 可批量赋值的字段
     */
    public $fillable = [
        'province_id',
        'temp_id',
        'city_id',
        'number',
        'price',
        'free_type',
        'uniqid'
    ];

    /**
     * 可搜索的字段
     */
    public $searchable = [
      'province_id',
      'temp_id',
      'city_id',
      'uniqid',
      'uniqid',
    ];

    /**
     * 默认倒序排序
     */
    protected $defaultSortCriteria = ['id,desc'];

    /**
     * 运费模板指定城市运费可关联所属的模板
     */
    public function province(){
        return $this->hasMany(ShippingTemplates::class,'temp_id','id');
    }

    /**
     * 运费模板指定城市运费可关联所属的城市
     */
    public function city(){
        return $this->hasMany(SystemCity::class,'city_id','id');
    }


}

